
/***************************************************************************
 *   jell - library                                                        *
 *                                                                         *
 *   Copyright (C) 2008 by kuerant                                         *
 *                         <kuerant@gmail.com>                             *
 *                                                                         *
 *   This library is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU Library General Public License as       *
 *   published by the Free Software Foundation; either version 2 of the    *
 *   License, or (at your option) any later version.                       *
 *                                                                         *
 *   This library is distributed in the hope that it will be usefull, but  *
 *   WITHOUT ANY WARRANTY; without even the implied warranty of            *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      *
 *   Library General Public License for more details.                      *
 *                                                                         *
 *   You should have received a copy of the GNU Library General Public     *
 *   License along with this library; if not, write to the Free Software   *
 *   Foundation, Inc., 59 Temple Place - Suite 330, Boston,                *
 *   MA 02111-1307, USA                                                    *
 ***************************************************************************/

#ifndef JEFI_BUF_HPP
#define JEFI_BUF_HPP

#include "jell/exception.hpp"

namespace   jell
{
    class   Buf
    {
    public  :
        typedef int     offset_type;

    public  :
        virtual const size_t    size    (void) const = 0;
        virtual const char*     data    (void) = 0;

        virtual const size_t    capacity(void) const = 0;
        virtual const void*     ptr     (void) = 0;

        virtual void clear(void) throw(JellException) = 0;
        virtual void assign(const char* data, size_t size) throw(JellException) = 0;
        virtual void append(const char* data, size_t size) throw(JellException) = 0;

    public  :
        // set size-of-data in buffer
        virtual void    size(size_t)                      = 0;

        virtual void    rewindRead(void)                  = 0;
        virtual void*   getReadPtr(void)                  = 0;
        virtual size_t  getSizeToRead(void) const         = 0;
        virtual void*   adjustReadPtr(const offset_type)  = 0;

        virtual void    rewindWrite(void)                 = 0;
        virtual void*   getWritePtr(void)                 = 0;
        virtual size_t  getSizeToWrite(void) const        = 0;
        virtual void*   adjustWritePtr(const offset_type) = 0;

    public  :
        virtual ~Buf() {}
    };  // class Buf
}   // namespace jell

#endif  // JEFI_BUF_HPP

